SET (HC12_ADDR_SPACE "$ENV{COPY}")

IF (NOT HC12_ADDR_SPACE)
    MESSAGE(WARN "You do not define HC12_ADDR_SPACE evnironment, use \"ABOOT\" for default")
    SET (HC12_ADDR_SPACE "ABOOT")
ENDIF (NOT HC12_ADDR_SPACE)

MESSAGE('HC12_ADDR_SPACE: ${HC12_ADDR_SPACE}')

IF ("${HC12_ADDR_SPACE}" STREQUAL "FBL")
    SET (TARGET_C_FLAGS        "${TARGET_C_FLAGS} -DFBL_XEP100=1 -DSTARTUP_XEP100")
    SET (TARGET_LINT_FLAGS     -i${CMAKE_CURRENT_LIST_DIR}/lint co-mwhc12_misra_c.lnt -u ${TARGET_LINT_FLAGS} -DFBL_XEP100=1 -DSTARTUP_XEP100 +D__PCLINT__)
    SET (TARGET_CXGATE_FLAGS   "${TARGET_CXGATE_FLAGS} -DFBL_XEP100=1 -DSTARTUP_XEP100")
    SET (HC12_PRM              "${CMAKE_CURRENT_LIST_DIR}/Project_FBL.prm")
ENDIF ("${HC12_ADDR_SPACE}" STREQUAL "FBL")

IF ("${HC12_ADDR_SPACE}" STREQUAL "ABOOT")
    SET (TARGET_C_FLAGS        "${TARGET_C_FLAGS} -DAPP_COPY_A -DSTARTUP_XEP100")
    SET (TARGET_LINT_FLAGS     -i${CMAKE_CURRENT_LIST_DIR}/lint co-mwhc12_misra_c.lnt -u ${TARGET_LINT_FLAGS} -DAPP_COPY_A -DSTARTUP_XEP100 +D__PCLINT__)
    SET (TARGET_CXGATE_FLAGS   "${TARGET_CXGATE_FLAGS} -DAPP_COPY_A")
    SET (HC12_PRM              "${CMAKE_CURRENT_LIST_DIR}/Project_ABOOT.prm")
ENDIF ("${HC12_ADDR_SPACE}" STREQUAL "ABOOT")


IF ("${HC12_ADDR_SPACE}" STREQUAL "A")
    SET (TARGET_C_FLAGS        "${TARGET_C_FLAGS} -DAPP_COPY_A")
    SET (TARGET_LINT_FLAGS     -i${CMAKE_CURRENT_LIST_DIR}/lint co-mwhc12_misra_c.lnt -u ${TARGET_LINT_FLAGS} -DAPP_COPY_A +D__PCLINT__)
    SET (TARGET_CXGATE_FLAGS   "${TARGET_CXGATE_FLAGS} -DAPP_COPY_A")
    SET (HC12_PRM              "${CMAKE_CURRENT_LIST_DIR}/Project_A.prm")
ENDIF ("${HC12_ADDR_SPACE}" STREQUAL "A")

IF ("${HC12_ADDR_SPACE}" STREQUAL "B")
    SET (TARGET_C_FLAGS        "${TARGET_C_FLAGS} -DAPP_COPY_B")
    SET (TARGET_LINT_FLAGS     -i${CMAKE_CURRENT_LIST_DIR}/lint co-mwhc12_misra_c.lnt -u ${TARGET_LINT_FLAGS} +D__PCLINT__)
    SET (TARGET_CXGATE_FLAGS   "${TARGET_CXGATE_FLAGS} -DAPP_COPY_B")
    SET (HC12_PRM              "${CMAKE_CURRENT_LIST_DIR}/Project_B.prm")
ENDIF ("${HC12_ADDR_SPACE}" STREQUAL "B")

INCLUDE ("${TOPDIR}/toolchain/Toolchain-Generic-chc12.cmake")
